/*
 * @(#)ColladaLoader.java 0.5 08/12/04
 *
 * Copyright 2008 100town.com. All rights reserved.
 * Use is subject to license terms.
 */
package org.collada.util;

import java.io.File;
import java.io.InputStream;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import org.collada.model.Model;

public abstract class ColladaLoader {
	public String colladaURI;
	public abstract Object load(Model model);
	public String getColladaURI() {
		return colladaURI;
	}
	public void setColladaURI(String colladaURI) {
		this.colladaURI = colladaURI;
	}
	public static Model unmarshal(InputStream input){
		try {
			JAXBContext context = JAXBContext.newInstance(Model.class);
			Unmarshaller unmarshaller = context.createUnmarshaller();
			Model model = (Model) unmarshaller.unmarshal(input);
			return model;
		} catch (JAXBException e) {
			e.printStackTrace();
			return null;
		}
	}
	public static Model unmarshal(File input){
		try {
			JAXBContext context = JAXBContext.newInstance(Model.class);
			Unmarshaller unmarshaller = context.createUnmarshaller();
			Model model = (Model) unmarshaller.unmarshal(input);
			return model;
		} catch (JAXBException e) {
			e.printStackTrace();
			return null;
		}
	}
	public abstract Object toRenderable(Model model);
}
